import { ref as O, markRaw as j, unref as i, defineComponent as Q, watch as I, openBlock as K, createElementBlock as E, createElementVNode as V, createVNode as P, withCtx as B, Fragment as D, renderList as N, createBlock as R, normalizeProps as A, guardReactiveProps as z } from "vue";
import { U as W } from "./useApi.C6EqDb1N.js";
import { g as n, k as w, bJ as J, j as M } from "./vendor.CF2kwqqq.js";
const L = [
  // kafka
  {
    "connection.config.bootstrapServers": "bootstrap.servers",
    "connection.config.saslUsername": "sasl.username",
    "connection.config.saslPassword": "sasl.password"
  },
  // topic
  {
    name: "topic",
    id: "group.id"
  }
], X = (o, T, f) => {
  const c = new W(), F = c.getKafkaList.bind(c), C = c.getTopicList.bind(c);
  let m = [], v = [];
  const h = O([]), _ = O([]), b = (o == null ? void 0 : o.kafkaOptionKey) || "connection.config.bootstrapServers", g = (o == null ? void 0 : o.topicOptionKey) || "name", y = (o == null ? void 0 : o.kafkaFormatKeys) || L[0], p = (o == null ? void 0 : o.topicFormatKeys) || L[1];
  F().then(async (e) => {
    m = e.data, h.value = e.data.map((t) => ({
      label: t.name,
      value: n(t, b),
      tag: j(w)
    }));
  });
  const u = async (e, t) => {
    if (!e)
      return;
    const a = await C(e);
    v = a.data, _.value = a.data.map((r) => ({
      label: r.name,
      value: n(r, g),
      tag: j(w)
    }));
  }, k = (e, t = !1) => {
    const a = U(e);
    a && u(a.name);
  }, s = (e) => {
    const t = y[b];
    return t ? i(e)[t] : "";
  }, l = (e) => {
    const t = p[g];
    return t ? i(e)[t] : "";
  }, U = (e) => {
    const t = J(h.value, (a) => a.value == e);
    if (t > -1)
      return m[t];
  }, Y = (e, t) => {
    const a = U(t);
    if (a) {
      u(a.name);
      const r = y;
      Object.keys(r).forEach((d) => {
        const S = n(r, d), x = n(a, d);
        e[S] = x;
      }), H(e);
    }
  }, q = (e) => {
    const t = J(_.value, (a) => a.value == e);
    if (t > -1)
      return v[t];
  }, G = (e, t) => {
    const a = q(t);
    if (a) {
      const r = p;
      Object.keys(r).forEach((d) => {
        const S = n(r, d), x = n(a, d);
        e[S] = x;
      });
    }
  }, H = (e) => {
    const t = p;
    Object.keys(t).forEach((a) => {
      const r = n(t, a), d = null;
      e[r] = d;
    });
  };
  return {
    kafkaList: m,
    topicList: v,
    kafkaOptions: h,
    topicOptions: _,
    NIFI_FORMAT_KEYS: L,
    initTopicList: k,
    topicChange: G,
    kafkaServerChange: Y,
    getKafkaValue: s,
    getTopicValue: l,
    initTopic: u
  };
}, Z = {
  "w-full": "",
  style: { "margin-bottom": "18px" }
}, $ = {
  flex: "",
  "flex-col": ""
}, tt = /* @__PURE__ */ V("b", null, "选择 kafka 连接", -1), et = {
  flex: "",
  "flex-col": ""
}, at = /* @__PURE__ */ V("b", null, "选择 TOPIC", -1), rt = /* @__PURE__ */ Q({
  __name: "kafka",
  props: {
    config: {},
    formdata: {},
    data: {},
    prop: {},
    graphShadowCell: {}
  },
  setup(o) {
    const T = o, { formdata: f, prop: c = "", graphShadowCell: F } = T, {
      kafkaOptions: C,
      topicOptions: m,
      kafkaServerChange: v,
      topicChange: h,
      getKafkaValue: _,
      getTopicValue: b
      // initTopicList,
    } = X(T.config), g = _(n(f, c)), y = b(n(f, c)), p = O(g), u = O(y);
    return I(p, (k) => {
      const s = n(f, c);
      v(s, k);
    }), I(u, (k) => {
      const s = n(f, c);
      h(s, k);
    }), (k, s) => (K(), E("div", Z, [
      V("div", $, [
        tt,
        P(i(M), {
          modelValue: p.value,
          "onUpdate:modelValue": s[0] || (s[0] = (l) => p.value = l)
        }, {
          default: B(() => [
            (K(!0), E(D, null, N(i(C), (l) => (K(), R(i(w), A(z(l)), null, 16))), 256))
          ]),
          _: 1
        }, 8, ["modelValue"])
      ]),
      V("div", et, [
        at,
        P(i(M), {
          modelValue: u.value,
          "onUpdate:modelValue": s[1] || (s[1] = (l) => u.value = l)
        }, {
          default: B(() => [
            (K(!0), E(D, null, N(i(m), (l) => (K(), R(i(w), A(z(l)), null, 16))), 256))
          ]),
          _: 1
        }, 8, ["modelValue"])
      ])
    ]));
  }
});
export {
  rt as _
};
